package com.yiidata.rpc.arpc;


import org.apache.avro.ipc.NettyTransceiver;
import org.apache.avro.ipc.Transceiver;
import org.apache.avro.ipc.specific.SpecificRequestor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.InetSocketAddress;


/**
 * <pre>
 *
 * Created by IntelliJ IDEA.
 * User: zhenqin
 * Date: 15/11/27
 * Time: 19:26
 * To change this template use File | Settings | File Templates.
 *
 * </pre>
 *
 * @author zhenqin
 */
public class AvroHelloWorldClient {

    /**
     * LOG
     */
    private final static Logger LOG = LoggerFactory.getLogger(AvroHelloWorldClient.class);


    public static void main(String[] args) throws Exception {
        String host = "localhost";
        int port = 8088;
        Transceiver t = new NettyTransceiver(new InetSocketAddress(host, port));
        AvroHelloWorldProtocol protocol = SpecificRequestor.getClient(AvroHelloWorldProtocol.class,
                new SpecificRequestor(AvroHelloWorldProtocol.class, t));
        Message message = protocol.sayHello(new User("AvroPRC"));
        System.out.println(message.getHi());

        t.close();
    }
}
